#ifndef TRANSACTION_HH
#define TRANSACTION_HH
#include <string>
#include <ctime>
#include <memory>
// Holds data for each transaction and handles transfer logic.
namespace Bank {
    class Customer;
    class IAccount;
    class BankSystem;
    enum class TransactionType {
        Deposit,
        Withdraw,
        Transfer
    };

    class Transaction {
    private:
        std::string transactionId;
        std::string sourceAccountId;
        std::string destinationAccountId;
        TransactionType type;
        double amount;
        std::string note;
        std::string timestamp;

        std::string getCurrentTimestamp() const;

        static int transactionCounter;  // static counters used to generate unique ID

    public:
        Transaction(const std::string& id, TransactionType type, double amount,
                    const std::string& srcAccId, const std::string& dstAccId = "",
                    const std::string& note = "");

        std::string getId() const;
        std::string getSourceAccountId() const;
        std::string getDestinationAccountId() const;
        TransactionType getType() const;
        double getAmount() const;
        std::string getNote() const;
        std::string getTimestamp() const;

        bool involvesCustomer(const std::shared_ptr<Customer>& customer) const;
        bool involvesAccount(const std::string& accountId) const;

        void display() const;
        std::string toString() const;

        static bool performTransfer(BankSystem& bank, const std::shared_ptr<IAccount>& from,
                                    const std::string& toAccountId, double amount,
                                    const std::string& note);

        static std::string generateUniqueTransactionID(); // create unique ID
    };
}
#endif